<!DOCTYPE html>
<html lang="zh" xmlns:th="https://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('黑名单编辑')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="blacklistAddForm" name="form-config-add">
        <input type="hidden" name="blacklistId" th:value="${blacklist.blacklistId}">
        <div class="form-group">
            <label class="col-sm-3 control-label">IP地址：</label>
            <div class="col-sm-8">
                <input id="ipAddr" name="ipAddr" class="form-control" type="text" th:value="${blacklist.ipAddr}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">封禁原因：</label>
            <div class="col-sm-8">
                <textarea name="description" class="form-control" th:text="${blacklist.description}"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "monitor/blacklist";

    $("#blacklistAddForm").validate({
        rules: {
            ipAddr: {
                required: true,
                rangelength: [2, 15],
            },
            description: {
                required: true,
                rangelength: [2, 80]
            },
            weight: {
                required: true,
                number: true
            },
        },
        messages: {
            "ipAddr": {
                required: "请输入IP地址",
                rangelength: "请输入长度为 {0} 至 {1} 之间的IP地址",
            },
            "description": {
                required: "请输入封禁原因",
                rangelength: "请输入长度为 {0} 至 {1} 之间的封禁原因"
            }
        },
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#blacklistAddForm').serializeArray();
            $.operate.update(prefix + "/edit", data);
        }
    }
</script>
</body>
</html>
